package a.e;

import a.c.d;
import a.c.m;
import a.c.w;
import a.i.n;
import a.j.g;
import a.j.tb;

import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class o
  extends e
{
  private g c;
  private Map d;
  private boolean e = false;
  private boolean f = true;
  public static int g;
  
  public void a(boolean paramBoolean)
  {
    this.e = paramBoolean;
  }
  
  public void b(boolean paramBoolean)
  {
    this.f = paramBoolean;
  }
  
  public boolean f()
  {
    return this.e;
  }
  
  public boolean g()
  {
    return this.f;
  }
  
  public String a()
  {
    return "TGF Format";
  }
  
  public String b()
  {
    return "tgf";
  }
  
  public void a(g paramg, InputStream paramInputStream)
    throws IOException
  {
    paramg.z();
    try
    {
      b(paramg, paramInputStream);
    }
    finally
    {
      paramg.A();
    }
  }
  
  private void b(g paramg, InputStream paramInputStream)
    throws IOException
  {
    int j = e.b;
    int i = e.a;
    this.d = new HashMap();
    this.c = paramg;
    StringBuffer localStringBuffer = new StringBuffer();
    BufferedReader localBufferedReader = new BufferedReader(new InputStreamReader(paramInputStream));
    do
    {
      do
      {
        String str;
        if ((str = localBufferedReader.readLine()) == null) {
          break;
        }
        localStringBuffer.append(str).append("\n");
        if (j != 0) {
          break label103;
        }
        if (i != 0) {
          break label99;
        }
      } while (i == 0);
    } while (j != 0);
    localBufferedReader.close();
    label99:
    if (localStringBuffer.length() == 0) {
      label103:
      return;
    }
    c(localStringBuffer.toString());
    this.d = null;
  }
  
  private void c(String paramString)
  {
    int j = e.b;
    int i = e.a;
    this.d.clear();
    StringTokenizer localStringTokenizer1 = new StringTokenizer(paramString, "#");
    if (j == 0) {
      if (localStringTokenizer1.countTokens() == 1)
      {
        if (j != 0) {
          break label69;
        }
        str2 = localStringTokenizer1.nextToken().trim();
        if (i == 0) {
          break label231;
        }
      }
    }
    label69:
    String str1 = localStringTokenizer1.nextToken().trim();
    String str2 = localStringTokenizer1.nextToken().trim();
    StringTokenizer localStringTokenizer2 = new StringTokenizer(str1, "\n\r");
    String str3;
    Object localObject1;
    Object localObject2;
    Object localObject3;
    Object localObject4;
    do
    {
      do
      {
        do
        {
          do
          {
            if (!localStringTokenizer2.hasMoreTokens()) {
              break;
            }
            str3 = null;
            localObject1 = localStringTokenizer2.nextToken();
            localObject2 = new StringTokenizer((String)localObject1);
            localObject3 = null;
            if ((j != 0) || (((StringTokenizer)localObject2).hasMoreTokens())) {
              str3 = ((StringTokenizer)localObject2).nextToken();
            }
            if (((StringTokenizer)localObject2).hasMoreTokens()) {
              localObject3 = ((String)localObject1).substring(str3.length()).trim();
            }
            localObject4 = this.c.i();
            this.d.put(str3, localObject4);
          } while (this.e);
          if ((j != 0) || (i != 0)) {
            break label254;
          }
        } while (localObject3 == null);
        this.c.a((a.c.e)localObject4, (String)localObject3);
      } while (j != 0);
    } while (i == 0);
    label231:
    localStringTokenizer2 = new StringTokenizer(str2, "\n\r");
    label392:
    label475:
    try
    {
      label254:
      do
      {
        do
        {
          d locald;
          do
          {
            do
            {
              do
              {
                if (!localStringTokenizer2.hasMoreTokens()) {
                  break;
                }
                str3 = localStringTokenizer2.nextToken();
                localObject1 = new StringTokenizer(str3);
                localObject2 = null;
              } while (!((StringTokenizer)localObject1).hasMoreTokens());
              localObject2 = ((StringTokenizer)localObject1).nextToken();
              str3 = str3.substring(((String)localObject2).length()).trim();
              if (j != 0) {
                break;
              }
              if (j == 0)
              {
                if (i != 0) {
                  break;
                }
                if (j != 0) {}
              }
              else if (!((StringTokenizer)localObject1).hasMoreTokens())
              {
                localObject3 = localObject2;
                localObject4 = null;
                if (j != 0) {
                  break label377;
                }
                if (i == 0) {
                  break label392;
                }
              }
              localObject3 = ((StringTokenizer)localObject1).nextToken();
              if (j == 0)
              {
                str3 = str3.substring(((String)localObject3).length()).trim();
                if (!((StringTokenizer)localObject1).hasMoreTokens()) {}
              }
              else
              {
                localObject4 = str3;
                if (i == 0) {
                  break label392;
                }
              }
              localObject4 = null;
              a.c.e locale1 = (a.c.e)this.d.get(localObject2);
              if (j == 0) {
                if (locale1 == null)
                {
                  locale1 = this.c.i();
                  this.d.put(localObject2, locale1);
                  if (j != 0) {
                    break label475;
                  }
                  if (!this.e) {
                    this.c.a(locale1, (String)localObject2);
                  }
                }
              }
              a.c.e locale2 = (a.c.e)this.d.get(localObject3);
              if (j == 0)
              {
                if (locale2 == null) {
                  locale2 = this.c.i();
                }
              }
              else
              {
                this.d.put(localObject3, locale2);
                if (j != 0) {
                  break label537;
                }
                if (!this.e) {
                  this.c.a(locale2, (String)localObject3);
                }
              }
              locald = this.c.a(locale1, locale2);
            } while (j != 0);
          } while ((this.f) || (localObject4 == null));
          this.c.a(locald, (String)localObject4);
        } while (j != 0);
      } while (i == 0);
    }
    catch (Exception localException)
    {
      label377:
      n.b(localException);
    }
    label537:
  }
  
  public void a(g paramg, OutputStream paramOutputStream)
    throws IOException
  {
    this.c = paramg;
    this.d = new HashMap();
    n.a(this, "saving in tgf format....");
    String str = h();
    paramOutputStream.write(str.getBytes(), 0, str.length());
    n.a(this, "done.");
    this.d = null;
  }
  
  private String h()
  {
    int j = e.b;
    int i = e.a;
    StringBuffer localStringBuffer = new StringBuffer();
    String str = System.getProperty("line.separator");
    Object localObject2;
    Object localObject3;
    if ((j != 0) || (!this.e))
    {
      localObject1 = this.c.v();
      do
      {
        if (!((w)localObject1).e()) {
          break;
        }
        localObject2 = ((w)localObject1).d();
        if (j != 0) {
          break label172;
        }
        localObject3 = this.c.x((a.c.e)localObject2).replace('\n', ' ').replace('\r', ' ');
        localStringBuffer.append(((a.c.e)localObject2).f() + 1);
        localStringBuffer.append(' ');
        localStringBuffer.append((String)localObject3);
        localStringBuffer.append(str);
        ((w)localObject1).f();
        if (i != 0) {
          break label168;
        }
      } while (i == 0);
    }
    if (j == 0) {
      localStringBuffer.append("#" + str);
    }
    label168:
    label172:
    Object localObject1 = this.c.w();
    do
    {
      if (!((m)localObject1).e()) {
        break;
      }
      localObject2 = ((m)localObject1).a();
      localStringBuffer.append(((d)localObject2).e().f() + 1);
      localStringBuffer.append(' ');
      if (j == 0)
      {
        if (i != 0) {
          break label336;
        }
        localStringBuffer.append(((d)localObject2).f().f() + 1);
      }
      if (j == 0)
      {
        if (!this.f)
        {
          localObject3 = this.c.t((d)localObject2);
          if (j != 0) {
            continue;
          }
          if (((tb)localObject3).V() > 0) {
            localStringBuffer.append(' ' + ((tb)localObject3).W().replace('\n', ' ').replace('\r', ' '));
          }
        }
        localStringBuffer.append(str);
        ((m)localObject1).f();
      }
    } while (i == 0);
    label336:
    return localStringBuffer.toString();
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.e.o

 * JD-Core Version:    0.7.0.1

 */